;;
;; @file    le-emacs-cscope.el
;; @created 2011/10/23
;; @updated 2011/12/23
;; @author  Gan Xiangle
;; @brief   For windows emacser who using cscope using the 
;;          xcscope.el, that bringing in the cscope package.
;;          this file configures xcscope.el's load path,
;;          etc.
;; @in      EMACS-DIR, a path string of emacs directory that contains le_plugins/
;;          and le_emacs_conf/
;; @usage  
;;    INSTALL on Windows
;;    
;;        (1) Download the cscope-win32 at http://code.google.com/p/cscope-win32/
;;            which contains the cscope.exe(and sort.exe used by cscope,windows itself
;;            have a not compatible sort)
;;        (2) The xcscope.el is included in cscope-15.7a.tar.gz source package
;;            (path: cscope-15.7a/contrib/xcscope/cscope.el).Add it to emacs
;;            load path.
;;        (3) The source package includes a bash util cscope-15.7a/contrib/xcscope/cscope-indexer,
;;            which can auto generate files list(usually 'cscope.files') and cscope database file
;;            (usually cscope.out).
;;            The cscope-indexer use find, egrep, sed, sort to generate files list(cscope.files),
;;            and then use cscope -b comand to gen database file(cscope.out)
;;        (4) Under windows, you can use Cynwin, which contains all utils used by cscope, as well 
;;            as cscope itself.
;;            However, there is native win program cscope.exe. And there is a perl version 
;;            cscope-indexer.pl, and a bat version cscope-indexer.bat for native use.
;;            Perl version: http://www.feelingbox.cn/archives/341
;;            Bat  version: http://www.emacswiki.org/emacs/CScopeAndEmacs
;;

;;    INSTALL ON Linux(ubuntu)
;;        (1) <REQUIREMENTS>
;;            $sudo apt-get install flex
;;            $sudo apt-get install bison
;;            $sudo apt-get install libncurses5-dev
;;        (2) <INSTALL COMMANDS>
;;            $tar zxvf cscope-15.7a.tar.gz
;;            $make distclean
;;            $./configure --with-flex
;;            $make
;;            $make install 
;;            $mv cscope-15.7a/  ~/.emacs.d/
;;            $cd path_to_cscope/
;;            $cp contrib/cscope/xcscope/cscope-indexer /usr/bin
;;            (or apt-get install cscope(or pacman cscope in Arch), 
;;             the xcscope.el is already in load-path of
;;             emacs, and cscope-indexer is in /usr/bin, all is done)
;;        (3) <CSCOPE-INDEXER>
;;            Changing the script file cscope-indexer, add -q option to 
;;            'cscope' command.(-q will Build an inverted index for quick 
;;            symbol searching.)
;;            $cscope -b -i $LIST_FILE -f $DATABASE_FILE -->
;;            $cscope -q -b -i $LIST_FILE -f $DATABASE_FILE
;;            [USAGE]
;;            Create files list and then database file cscope.out using 
;;            cscope-indexer:
;;            $cd PATH_TO_SOURCE/
;;            $cscope-indexer -r

(defvar le-cscope-path
  (concat EMACS_DIR "le_plugins/cscope-15.7a/contrib/xcscope"))

(add-to-list 'load-path le-cscope-path)
(require 'xcscope)

(setq cscope-do-not-update-database t)
(define-key global-map [(ctrl f1)]  'cscope-display-buffer-toggle) 
(define-key global-map [(ctrl f2)]  'cscope-index-files) 
(define-key global-map [(ctrl f3)]  'cscope-find-called-functions) 
(define-key global-map [(ctrl f4)]  'cscope-find-functions-calling-this-function)
(define-key global-map [(ctrl f5)]  'cscope-find-egrep-pattern)
(define-key global-map [(ctrl f6)]  'cscope-find-this-symbol)
(define-key global-map [(ctrl f7)]  'cscope-find-global-definition)
(define-key global-map [(ctrl f8)]  'cscope-find-this-text-string) 	
(define-key global-map [(ctrl f9)]  'cscope-prev-symbol)
(define-key global-map [(ctrl f10)] 'cscope-next-symbol)
(define-key global-map (kbd "C--")  'cscope-prev-file)
(define-key global-map (kbd "C-=")  'cscope-next-file) 	
(define-key global-map (kbd "C-\\") 'cscope-pop-mark) 
(define-key global-map [(meta f11)] 'cscope-find-this-file) 	
(define-key global-map [(meta f12)] 'cscope-find-files-including-file)











